<div id="content" class="container_12">
    <?php
    
    if(!isset($profile_id) OR !isset($fname) OR !isset($lname) OR !isset($gender) OR !isset($birthday)) {
        echo '<div class="error"><img src="'.base_url().'/images/error.png" alt="error" class="valign-middle" />
        <span class="valign-middle">Account not recognized. Given data might be invalid or missing.</span></div>';
    } else {
    ?>
    <div class="grid_3">
        <?php
        
        if($avatar != null) {
            echo '<img src="'.base_url().'account/getavatar/'.$_GET['id'].'" alt="avatar" class="avatar" />';
        } else {
            echo '<img src="'.base_url().'images/unknown_user.jpg" alt="avatar" class="avatar" />';
        }
        
        ?>
    </div>
    <div class="grid_9">
        <div class="header-border">
            <?php
            
            if($this->session->userdata('account_id') != $_GET['id']) {
                switch($relationship) {
                    case -1:
                        echo '<input type="button" value="Add Friend" class="silver-button float-right" onClick="anchor(\''.base_url().'friend/sendRequest?action=send&amp;id='.$_GET['id'].'&amp;id2='.$this->session->userdata('account_id').'\')" />';
                        break;
                    case 0:
                        echo '<input type="button" value="&#10004; Friend Request Sent" class="silver-button float-right" disabled />';
                        echo '<input type="button" value="Cancel Friend Request" onClick="anchor(\'\');" class="silver-button float-right" />';
                        break;
                    case 1:
                        echo '<input type="button" value="&#x2713; Friends" class="silver-button float-right" disabled />';
                        echo '<input type="button" value="Delete Friend" onClick="anchor(\'\');" class="silver-button float-right" />';
                        break;
                    case 2:
                        echo '<input type="button" value="Decline Friend Req." onClick="anchor(\'\');" class="silver-button float-right" />';
                        echo '<input type="button" value="Accept Friend Req." onClick="anchor(\'\');" class="silver-button float-right" />';
                }
            } else {
                echo '<input type="button" name="edit" value="Edit Profile" onClick="anchor(\''.base_url().'account/profile?action=update&amp;id='.$_GET['id'].'\')" class="silver-button float-right" />';
            }
            
            ?>
            <h2><?php echo $fname." ".$lname; ?></h2>
        </div>
        <?php
        
        if(isset($_GET['succ'])) {
            echo '
            <div class="success"><img src="'.base_url().'images/success.png" alt="success" class="valign-middle" />
            <span class="valign-middle">
            ';
            switch($_GET['succ']) {
                case 1:
                    echo 'Profile updated successfully!';
            }
            echo '
            </span>
            </div><br />';
        } else if(isset($_GET['err'])) {
            echo '
            <div class="error">';
            
            if($_GET['err'] != 4) {
                echo '
                <img src="'.base_url().'images/error.png" alt="error" class="valign-middle" />
                <span class="valign-middle">
                ';
            } else {
                echo '
                <img src="'.base_url().'images/foreveralone.png" alt="foreveralone" class="valign-middle" />
                <span class="valign-middle">
                ';
            }
            
            switch($_GET['err']) {
                case 1:
                    echo 'There is already an existing friend request between these users!';
                    break;
                case 2:
                    echo 'These two users are already friends!';
                    break;
                case 3:
                    echo 'Data provided seems invalid!';
                    break;
                case 4:
                    echo 'Adding yourself as a friend?';
            }
            echo '
            </span>
            </div><br />';
        }
        
        if($this->session->userdata('account_id') == $_GET['id']) {
        ?>
        <fieldset>
        <legend>Account Information</legend>
        <table class="tbl">
            <tr>
                <td class="tbl-td-a align-right"><span>Username</span></td>
                <td><?php echo $username; ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Password</span></td>
                <td>******</td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Account Role</span></td>
                <td><?php echo $this->session->userdata('role'); ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Account Status</span></td>
                <td><?php if($status == 1){echo "Active";}else{echo "Inactive";} ?></td>
            </tr>
        </table>
        </fieldset>
        <br />
        <?php } ?>
        <fieldset>
        <legend>Profile Information</legend>
        <table class="tbl">
            <tr>
                <td class="tbl-td-a align-right"><span>First Name</span></td>
                <td><?php echo $fname; ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Last Name</span></td>
                <td><?php echo $lname; ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Gender</span></td>
                <td><?php echo $gender; ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Birthday</span></td>
                <td><?php echo $birthday; ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>Address</span></td>
                <td><?php echo $address; ?></td>
            </tr>
            <tr>
                <td class="tbl-td-a align-right"><span>About Me</span></td>
                <td><?php echo nl2br($about); ?></td>
            </tr>
        </table>
        </fieldset>
    </div>
    <?php } ?>
</div>